package javabase.desginpattern.structure.flyweight;

/**
 * @author fance
 * @date 18-4-28 下午1:12
 */
public class FlyweightPattern {
    FlyweightFactory flyweightFactory = new FlyweightFactory();

    Flyweight flyweight1;
    Flyweight flyweight2;
    Flyweight flyweight3;
    Flyweight flyweight4;
    Flyweight flyweight5;
    Flyweight flyweight6;

    public FlyweightPattern() {
        flyweight1 = flyweightFactory.getFlyweight("goole");
        flyweight2 = flyweightFactory.getFlyweight("qutr");
        flyweight3 = flyweightFactory.getFlyweight("goole");
        flyweight4 = flyweightFactory.getFlyweight("goole");
        flyweight5 = flyweightFactory.getFlyweight("goole");
        flyweight6 = flyweightFactory.getFlyweight("goole");
    }

    public void show() {
        flyweight1.operation();
        flyweight2.operation();
        flyweight3.operation();
        flyweight4.operation();
        flyweight5.operation();
        flyweight6.operation();
        int size = flyweightFactory.getFlyweightSize();
        System.out.println("size : " + size);
    }

    public static void main(String[] args) {
        FlyweightPattern flyweightPattern = new FlyweightPattern();
        flyweightPattern.show();
    }
}
